$(function(){
    $.ajax({
    	'url': '/expMng/setting.do',
    	'contentType' : "application/json",
		'success': function(data){
			var checking = data.checking;
			var checked = data.checked;
			$('#leftSelect').empty();
			$('#rightSelect').empty();
			$.each(checking,function(i,v){
				$('#leftSelect').append('<option value="'+v.keyword+'">'+v.keyword+'</option>');
			});
			$.each(checked,function(i,v){
				$('#rightSelect').append('<option value="'+v.keyword+'">'+v.keyword+'</option>');
			});
			$('select#leftSelect').listbox();
		    $('select#rightSelect').listbox();
		}
    });
    $('#add').on('click',function(){
    	var leftCtn = $('#keywordPanel .leftContainer .lbjs-list');
    	var rightCtn = $('#keywordPanel .rightContainer .lbjs-list');
    	var selected = leftCtn.children('.lbjs-item').filter('[selected]');
    	var keywords = '';
    	if(!selected.length)
    		return ;
    	selected.each(function(i){
    		keywords += $(this).text()+',';
    	});
    	console.log('selected:' + selected);
    	console.log(keywords);
    	$.ajax({
    		'url': '/expMng/set.do',
//    		'type': 'POST',
    		'data': {
    			'state': 1,
    			'keywords': keywords.substring(0,keywords.length-1)
    		},
//    		'traditional': true,
    		'contentType' : "application/json",
    		'success': function(data){
    			
    	    	rightCtn.append(selected);
    		}
    	});
    });
    $('#remove').on('click',function(){
    	
    });
    $('#addAll').on('click',function(){
    	
    });
    $('#removeAll').on('click',function(){
    	
    });
})